package cpgears.movie {
	import asunit.framework.TestCase;
	import cpgears.BaseImplMock;
	import cpgears.movie.container.ContainerType;
	import cpgears.properties.WidgetPropertiesBase;
	
	/**
	 * ...
	 * @author Whyves
	 */
	public class MoviePropertiesTest extends TestCase{
		
		private var mWidgetProperties:WidgetPropertiesBase = null;
		
		public function MoviePropertiesTest(testMethod:String = null) {
			super(testMethod);
		}
		
		override protected function setUp():void {
			mWidgetProperties = new WidgetPropertiesBase()
		}

		//---------------------------------------------------------------------
		//  Content
		//---------------------------------------------------------------------
		public function testMovieContent():void {
			triggerEnterRuntime(assertMovieContent);
		}
		
		private function assertMovieContent(functionCalled:String, properties:Object, movie:IMovie):void {
			assertEquals(100, movie.contentWidth);
			assertEquals(200, movie.contentHeight);
		}

		//---------------------------------------------------------------------
		//  Version
		//---------------------------------------------------------------------
		public function testMovieVersion():void {
			triggerEnterRuntime(assertMovieVersion);
		}
		
		private function assertMovieVersion(functionCalled:String, properties:Object, movie:IMovie):void {
			assertEquals("5.0.0", movie.captivateVersion.toString());
		}
		
		//---------------------------------------------------------------------
		//  Event Dispatcher
		//---------------------------------------------------------------------
		public function testMovieEventDispatcher():void {
			triggerEnterRuntime(assertMovieEventDispatcher);
		}
		
		private function assertMovieEventDispatcher(functionCalled:String, properties:Object, movie:IMovie):void {
			assertNotNull(movie.addEventListener);
		}
		
		//---------------------------------------------------------------------
		//
		//  Helper functions
		//
		//---------------------------------------------------------------------
		
		private function triggerEnterRuntime(callback:Function):void {
			var handler:Function = addAsync(callback, 500);
			var widget:BaseImplMock = new BaseImplMock(handler);
			widget.cpSetValue("movieHandle",  new MovieMock(mWidgetProperties));
		}
	}
}